|
|
|
|
|
|
|
Visual InterDevAnother Microsoft product, aimed more at developers of database-driven Web pages; it generates VBScript code for you. |
|
|
|
|
|
|
|
|
Internet Client SDKSoftware development kit available for downloading from Microsoft; it provides samples, documentation, and utilities for working with the Internet. |
|
|
|
|
|
|
|
|
When compared to standard VB, VBScript could almost be called ''VB-Stripped" because it lacks so many functions. However, this is by design; the power of VBScript is in where it can be used and the objects it can access rather than in the language itself. Therefore, using VBScript will take some adjusting if you are used to Visual Basic. |
|
|
|
|
|
|
|
|
Working with Variants Only |
|
|
|
|
|
|
|
|
Perhaps the most striking difference between VB and VBScript is that all variables in VBScript are variants. The following statements are valid VBScript declarations: |
|
|
|
|
|
|
|
|
Dim sLastName
Dim nCounter
Dim myArray(2,5) |
|
|
|
|
|
|
|
|
VBScript does not allow a standard VB declaration with the As keyword. If you attempt to include one, you receive an error. The variant-only rule also applies to all variables used in subs and functions: |
|
|
|
|
|
|
|
|
Function CalcInterest(P,R,T)
CalcInterest = P * R * T
End Function |
|
|
|
|
|
|
|
|
In the CalcInterest sample function, all the parameters and the return value are variants. The calling code could legally assign the string "Hello" to one of the parameters, although a type mismatch error would occur in the multiplication statement. For this reason, I strongly suggest adhering to the variable naming conventions you use in regular Visual Basic. You can also use the Option Explicit statement in the header of your Web page to require variable declarations. |
|
|
|
|
|
|
|
|
Several functions in VBScript also can be used to determine the type of variable being stored in a variant. They are summarized in Table 30.3. |
|
|
|
|
| Table 30.3 Determining a Variable Type in VBScript | | Function(s) | Purpose | | VarType(varname) | Returns a constant | | TypeName(varname) | Returns a description | | Is() . . . functions | Checks for specific types and conditions |
|
|
|